package com.cino.demos.sourceCode.AOPdemo;

public class AroundAdviceInterceptor implements MethodInterceptor {
    private final String adviceName;
    
    public AroundAdviceInterceptor(String adviceName) {
        this.adviceName = adviceName;
    }
    
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        System.out.println("  🔧 [" + adviceName + "] 环绕通知开始");
        long start = System.currentTimeMillis();
        
        try {
            Object result = invocation.proceed(); // 执行下一个拦截器
            System.out.println("  🔧 [" + adviceName + "] 环绕通知结束，耗时: " + (System.currentTimeMillis() - start) + "ms");
            return result;
        } catch (Exception e) {
            System.out.println("  🔧 [" + adviceName + "] 环绕通知捕获异常: " + e.getMessage());
            throw e;
        }
    }

}